package com.chapter4.lianxi.demo2;

public class Person {

    public String name;
    public int age;
    public boolean gender;
    public Person partner;

    public Person(){

    }

    public Person(String name, int age, boolean gender, Person partner) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.partner = partner;
    }
    public void marry(Person p){

        if(this.gender==p.gender){
            System.out.println(this.name +"和"+p.name+"性别相同，不能结婚");
        } else if(this.gender==true && this.age<22){
            System.out.println(this.name+"未达到法定结婚年龄，不能结婚;");
        } else if(this.gender==false && this.age<20){
            System.out.println(this.name+"未达到法定结婚年龄，不能结婚;");
        } else if(p.gender==true && p.age<22){
            System.out.println(p.name+"未达到法定结婚年龄，不能结婚;");
        } else if(p.gender==false && p.age<20){
            System.out.println(p.name+"未达到法定结婚年龄，不能结婚;");
        } else if(this.partner!=null){
            System.out.println(this.name+"已结婚;");
        } else if(p.partner!=null){
            System.out.println(p.name+"已结婚;");
        } else{
            System.out.println("新婚快乐");
        }
    }

}